/*
 * Copyright 2007 Ulf Ochsenfahrt <ulf@ofahrt.de>
 *
 * This file is part of mnemoj, a software transactional memory implementation
 * that is based on Project Darkstar.
 *
 * mnemoj is free software: you can redistribute it
 * and/or modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation and
 * distributed hereunder to you.
 *
 * Project Darkstar Server is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.ofahrt.mnemoj.impl;

import java.io.Serializable;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

final class Binding implements Serializable
{

private static final long serialVersionUID = 1L;

private final String id;
private final Lock lock = new ReentrantLock();
private ManagedReferenceImpl ref = null;

public Binding(String id, ManagedReferenceImpl ref)
{
	this.id = id;
	this.ref = ref;
}

public Binding(String id)
{ this(id, null); }

public String getId()
{ return id; }

public Lock getLock()
{ return lock; }

public ManagedReferenceImpl get()
{ return ref; }

public void set(ManagedReferenceImpl newref)
{ this.ref = newref; }

public boolean isNew()
{ return ref == null; }

}
